/*
 *---------------------------------------------------------------------------
 *
 * Copyright (c) 2020, 2021 Analog Devices, Inc. All Rights Reserved.
 * This software is proprietary to Analog Devices, Inc.
 * and its licensors.By using this software you agree to the terms of the
 * associated Analog Devices Software License Agreement.
 *
 *---------------------------------------------------------------------------
 */
#include "sfe_spe_advanced.h"

/* Extra 4 bytes for FCS and 2 bytes for the frame header */
#define MAX_FRAME_BUF_SIZE  (MAX_FRAME_SIZE + 4 + 2)

#define TEST_FRAMES_COUNT   (2)

#define MAC_ADDR_0_0        (0x00)
#define MAC_ADDR_0_1        (0xE0)
#define MAC_ADDR_0_2        (0x22)
#define MAC_ADDR_0_3        (0xFE)
#define MAC_ADDR_0_4        (0xDA)
#define MAC_ADDR_0_5        (0xC9)

#define MAC_ADDR_1_0        (0x00)
#define MAC_ADDR_1_1        (0xE0)
#define MAC_ADDR_1_2        (0x22)
#define MAC_ADDR_1_3        (0xFE)
#define MAC_ADDR_1_4        (0xDA)
#define MAC_ADDR_1_5        (0xCA)

uint8_t macAddr[2][6] = {
    {MAC_ADDR_0_0, MAC_ADDR_0_1, MAC_ADDR_0_2, MAC_ADDR_0_3, MAC_ADDR_0_4, MAC_ADDR_0_5},
    {MAC_ADDR_1_0, MAC_ADDR_1_1, MAC_ADDR_1_2, MAC_ADDR_1_3, MAC_ADDR_1_4, MAC_ADDR_1_5},
};

uint8_t testFrames[TEST_FRAMES_COUNT][MAX_FRAME_SIZE] =
{
    {
        MAC_ADDR_0_0, MAC_ADDR_0_1, MAC_ADDR_0_2, MAC_ADDR_0_3, MAC_ADDR_0_4, MAC_ADDR_0_5,
        MAC_ADDR_1_0, MAC_ADDR_1_1, MAC_ADDR_1_2, MAC_ADDR_1_3, MAC_ADDR_1_4, MAC_ADDR_1_5,
        0x08, 0x00,
        0x00, 0x00, 0x00, 0x00,
        0xC5, 0xDA, 0x48, 0x9A, 0x67, 0xA0, 0xBE, 0x3B,
        0x44, 0x64, 0xE1, 0xF3, 0x7E, 0x1D, 0x5F, 0x6C,
        0x7B, 0x56, 0xA1, 0xFB, 0xCF, 0xEE, 0xFD, 0xCE,
        0xAE, 0xAC, 0xA7, 0xE0, 0x9F, 0x17, 0x62, 0xA7,
        0x39, 0x27, 0xA4, 0xDC, 0xD9, 0x61, 0xA0, 0x20,
        0xB4, 0x6F, 0x31, 0x69, 0x01, 0xA0, 0x75, 0xCA,
        0xAD, 0x42, 0x0C, 0xC7, 0xF3, 0x7E, 0xF2, 0x62,
        0x27, 0x5A, 0x19, 0xF5, 0xFB, 0xD7, 0x3F, 0x9B,
        0xB1, 0x2A, 0x4F, 0xDD, 0x95, 0x04, 0xB2, 0x46,
        0x2B, 0x26, 0x2C, 0x6F, 0x4A, 0x02, 0xA5, 0xD0,
        0xFE, 0x6F, 0xAB, 0xC6, 0xB6, 0x5B, 0x2B, 0xAA,
        0x94, 0xB6, 0xDC, 0x42, 0x48, 0x81, 0x27, 0x9C,
        0xA1, 0xBD, 0x10, 0x6B, 0xD1, 0x03, 0x14, 0xDF,
        0x0C, 0xD9, 0x9A, 0xE1, 0x92, 0x3B, 0x02, 0xAF,
        0xD8, 0x46, 0x3F, 0xC1, 0x83, 0xB9, 0x85, 0xAF,
        0x9B, 0x2C, 0x7B, 0x01, 0x10, 0xD2, 0xED, 0x62,
        0xBD, 0x52, 0x5F, 0xDA, 0xF7, 0x19, 0x5D, 0x46,
        0x82, 0x6F, 0xE2, 0x7E, 0xC7, 0xCC, 0xFC, 0x3A,
        0x32, 0xF3, 0xF5, 0x8F, 0xC8, 0x1A, 0x41, 0x73,
        0xB7, 0x41, 0x8C, 0x1F, 0x24, 0x92, 0xDB, 0x36,
        0xEB, 0xAE, 0x41, 0xAF, 0xF6, 0x76, 0x75, 0x59,
        0xEC, 0x28, 0xD0, 0x5A, 0x85, 0x66, 0xE0, 0xDC,
        0x4E, 0xE7, 0x83, 0x51, 0x44, 0xE2, 0xD6, 0xE0,
        0xB4, 0x0C, 0xCB, 0x4E, 0xB9, 0x45, 0xCC, 0xF5,
        0xB5, 0xCD, 0xB2, 0xCB, 0xD7, 0xE0, 0x9A, 0x41,
        0xDE, 0x5A, 0x14, 0xA0, 0x85, 0x54, 0x6E, 0xD9,
        0x43, 0xC6, 0xF6, 0x15, 0xC7, 0xF8, 0x90, 0x9D,
        0x38, 0x62, 0x56, 0xF6, 0x86, 0xA3, 0x91, 0x0D,
        0xA9, 0xDE, 0xD0, 0x22, 0x4E, 0x37, 0x1D, 0x92,
        0x33, 0x2A, 0x99, 0x24, 0x94, 0xD1, 0xE8, 0x17,
        0xF3, 0x12, 0x8C, 0x9F, 0x98, 0x62, 0xBB, 0x9A,
        0x49, 0xE0, 0x9A, 0xF9, 0x19, 0xF9, 0x5E, 0x9E,
        0x4F, 0x7B, 0x81, 0xE6, 0x16, 0x40, 0x18, 0x04,
        0x4E, 0xD4, 0xA6, 0x47, 0x64, 0xA5, 0x60, 0x5C,
        0xFA, 0x0A, 0xA6, 0x82, 0x06, 0x81, 0x02, 0x11,
        0x43, 0xFD, 0xBF, 0x3C, 0x68, 0x7E, 0x20, 0x6E,
        0xB4, 0x50, 0x82, 0xEE, 0x20, 0x5E, 0x78, 0xB2,
        0x3B, 0x65, 0xE3, 0x74, 0x33, 0xA2, 0x34, 0x21,
        0xB4, 0xD0, 0xCB, 0xD2, 0xF2, 0x46, 0x21, 0x82,
        0xF1, 0x33, 0x84, 0x52, 0x5F, 0x3A, 0x97, 0xC2,
        0x15, 0x00, 0xF4, 0x7E, 0x8F, 0xB8, 0xFD, 0x67,
        0x94, 0x08, 0xB5, 0x56, 0x3A, 0x59, 0xFC, 0x38,
        0xED, 0xA2, 0x32, 0x4D, 0xB2, 0x30, 0x68, 0x86,
        0x42, 0xF4, 0xB6, 0x99, 0x91, 0xAF, 0x3A, 0x6E,
        0x7D, 0xB4, 0xD5, 0xBD, 0x6D, 0x1A, 0xEE, 0x31,
        0x5E, 0x83, 0x18, 0x9F, 0x31, 0x80, 0x92, 0x65,
        0x5D, 0x3A, 0xC3, 0x66, 0x70, 0x0D, 0x34, 0x51,
        0xF6, 0x9F, 0xD0, 0x2C, 0xE7, 0xB0, 0xA2, 0xEF,
        0x75, 0x66, 0x41, 0x0F, 0xD3, 0xCC, 0xE0, 0x93,
        0x8D, 0x19, 0xC8, 0x73, 0x22, 0x44, 0x6D, 0x1F,
        0xB6, 0xED, 0x78, 0xCF, 0xDC, 0x53, 0x6B, 0x6D,
        0x3A, 0x40, 0xCA, 0x6F, 0xBD, 0x00, 0xB4, 0x41,
        0x6D, 0xD5, 0x28, 0x98, 0x57, 0x6E, 0xE3, 0x12,
        0x1E, 0x46, 0x51, 0xF0, 0xE9, 0xBA, 0x16, 0x4A,
        0x40, 0xE1, 0x43, 0x8D, 0x5A, 0x85, 0x1B, 0x65,
        0x0A, 0x36, 0x99, 0xF1, 0xD3, 0x55, 0xCF, 0x55,
        0x36, 0xB1, 0x68, 0xEB, 0xA6, 0xBB, 0x7A, 0x96,
        0x18, 0x51, 0xAF, 0x6D, 0x2C, 0x91, 0x6D, 0x81,
        0x60, 0x67, 0xD0, 0x8B, 0x92, 0x3D, 0x9E, 0xC9,
        0x52, 0x4C, 0x2F, 0x3F, 0x57, 0xB6, 0xE9, 0x6E,
        0xCF, 0x32, 0x46, 0x53, 0xD3, 0x4F, 0x04, 0x51,
        0x00, 0xD6, 0x5F, 0x45, 0xE8, 0xA1, 0xBB, 0x7A,
        0x52, 0x3C, 0xBF, 0x96, 0x31, 0xDD, 0x8B, 0xB9,
        0x54, 0xB8, 0x27, 0x09, 0xA8, 0x76, 0x70, 0x5B,
        0xF6, 0x85, 0x41, 0x10, 0x9D, 0x1E, 0xEF, 0x71,
        0x99, 0x9D, 0xD8, 0x80, 0x4D, 0x2D, 0xEC, 0x09,
        0x47, 0x1C, 0xB8, 0xED, 0x3B, 0x9F, 0x1A, 0x73,
        0x14, 0x5B, 0x08, 0xBA, 0x59, 0x31, 0x8F, 0x84,
        0x39, 0xD6, 0x98, 0x5A, 0xA1, 0x55, 0xFF, 0x4A,
        0x82, 0x74, 0x9C, 0x5D, 0xC3, 0x44, 0xEF, 0x96,
        0x84, 0xB2, 0x78, 0x65, 0x0E, 0x05, 0x7E, 0x3D,
        0xB5, 0xA7, 0x1F, 0x7A, 0x72, 0xA6, 0x9C, 0x15,
        0x5F, 0x39, 0xBC, 0x37, 0x2F, 0xE7, 0x2D, 0x79,
        0xFB, 0xE7, 0x0F, 0x8B, 0x22, 0x9B, 0x64, 0x0E,
        0x0C, 0xCD, 0xE7, 0x90, 0x5E, 0x42, 0x29, 0x80,
        0x20, 0xAF, 0x25, 0x21, 0x84, 0x48, 0x92, 0x3D,
        0xE9, 0x8B, 0x4F, 0x75, 0x98, 0x0E, 0xA0, 0xC7,
        0x3E, 0xC6, 0xC4, 0x3F, 0x7E, 0x8A, 0x5D, 0xB3,
        0x88, 0xE2, 0xB4, 0xF7, 0xDE, 0x55, 0x02, 0x9F,
        0x0E, 0xE2, 0x6B, 0xB3, 0x19, 0xBE, 0x00, 0xE4,
        0xE2, 0x56, 0x82, 0xF5, 0x84, 0x35, 0x7D, 0xFC,
        0x14, 0x81, 0xB5, 0x88, 0xC4, 0x82, 0x79, 0x58,
        0x33, 0x09, 0x45, 0x37, 0xDF, 0x11, 0xB7, 0x1C,
        0x09, 0x8D, 0x92, 0x4A, 0xF7, 0x4F, 0x39, 0xAD,
        0x23, 0xE0, 0x31, 0xEA, 0xFA, 0x4A, 0x6C, 0x4B,
        0xFB, 0x77, 0xE8, 0x11, 0xC9, 0x2A, 0xF2, 0x5D,
        0x91, 0x2A, 0x95, 0xB7, 0x9E, 0x9C, 0xA9, 0x1E,
        0x84, 0xA5, 0xB5, 0x78, 0xF8, 0xF7, 0x9B, 0x26,
        0x93, 0x0B, 0x91, 0x4C, 0x1D, 0x9E, 0x7C, 0xB0,
        0x4B, 0x05, 0xB6, 0x59, 0xAD, 0x55, 0x1C, 0x31,
        0x0F, 0x6E, 0x52, 0xBD, 0xDD, 0x09, 0x60, 0x39,
        0x88, 0x41, 0x10, 0xB3, 0xE1, 0x37, 0x6E, 0x20,
        0x1A, 0xC1, 0x7E, 0xB1, 0x82, 0x27, 0xEE, 0xC2,
        0x25, 0xF7, 0xF8, 0x4F, 0xB1, 0x59, 0xBD, 0x6C,
        0x0D, 0x51, 0x83, 0x0D, 0xB7, 0x95, 0xB1, 0x12,
        0x7D, 0x82, 0xE1, 0xCC, 0x68, 0xD0, 0x6A, 0xE9,
        0x71, 0x8A, 0xEA, 0xEC, 0x63, 0x14, 0x79, 0x72,
        0x8D, 0xD1, 0x0F, 0x98, 0xA1, 0x08, 0x90, 0x48,
        0x09, 0x78, 0xBB, 0x33, 0x40, 0xE7, 0x5C, 0x67,
        0x68, 0xC8, 0xE0, 0xE0, 0xA0, 0xA3, 0x11, 0x65,
        0x1E, 0xEB, 0xE9, 0x69, 0xFC, 0x21, 0xD2, 0xDD,
        0xE1, 0xB1, 0x4D, 0x26, 0xEF, 0x45, 0xE9, 0xAD,
        0x11, 0x39, 0x41, 0xE4, 0xF1, 0x36, 0xDF, 0xF7,
        0x5F, 0x68, 0xBF, 0xDA, 0xC6, 0x23, 0xE8, 0x20,
        0x7B, 0xF5, 0x3B, 0xC9, 0x21, 0x07, 0xBA, 0x7C,
        0xDF, 0xCE, 0x01, 0x0D, 0xF2, 0xB1, 0xE5, 0xD5,
        0xE2, 0xAA, 0x20, 0x3C, 0x9B, 0x03, 0x81, 0xE2,
        0x93, 0xB0, 0x50, 0x5F, 0x1A, 0xD8, 0x8B, 0x40,
        0x74, 0x0F, 0x6E, 0xDE, 0xB4, 0x77, 0x9A, 0x91,
        0x27, 0xAA, 0x1E, 0x73, 0xD3, 0x95, 0x87, 0xE0,
        0x32, 0xD5, 0xA5, 0xAC, 0x64, 0x86, 0x3E, 0x1C,
        0x6F, 0xAB, 0xA1, 0x66, 0x78, 0xB2, 0xE2, 0xE3,
        0x1C, 0xAB, 0xAB, 0xD4, 0x3E, 0xEE, 0x79, 0x0E,
        0x26, 0xD0, 0x0F, 0xC8, 0xC2, 0xDF, 0x12, 0xDC,
        0x9B, 0x7C, 0x39, 0x40, 0x74, 0x22, 0x57, 0x64,
        0x00, 0xF7, 0xBB, 0xFA, 0xB4, 0x7E, 0xF6, 0xE2,
        0x40, 0x6A, 0x92, 0x4E, 0x54, 0xD7, 0x65, 0xE1,
        0x7D, 0xBD, 0xBB, 0xC5, 0x07, 0xEA, 0xEF, 0x4B,
        0xC5, 0x4F, 0xEB, 0x2D, 0x3F, 0x26, 0xE9, 0x33,
        0xBB, 0x8B, 0x2C, 0xBE, 0x88, 0x99, 0x86, 0x05,
        0x10, 0x13, 0xEA, 0x5C, 0x1C, 0xDF, 0x59, 0x63,
        0xEA, 0xBD, 0x43, 0xAC, 0xB3, 0x47, 0x5A, 0x31,
        0x9F, 0x6F, 0x28, 0x1B, 0xCC, 0xB6, 0xD5, 0x50,
        0x2B, 0xA0, 0xB0, 0xB2, 0xB5, 0x32, 0x94, 0xA6,
        0x7B, 0xC6, 0x45, 0x97, 0x8F, 0xA2, 0xD8, 0x5A,
        0x45, 0x6E, 0xAF, 0xBA, 0xE1, 0xF2, 0xB5, 0x73,
        0xC0, 0x7E, 0xE2, 0xDB, 0xAE, 0x10, 0xFE, 0xCC,
        0x18, 0xCB, 0xFE, 0x2E, 0x3A, 0xD4, 0x67, 0x81,
        0xEA, 0x8E, 0xBD, 0x74, 0x28, 0x9D, 0xD8, 0x28,
        0x00, 0x2D, 0x3B, 0xAC, 0x72, 0xF4, 0xD1, 0x12,
        0x68, 0xC2, 0x1D, 0xF3, 0x01, 0x04, 0x78, 0x64,
        0x7F, 0x66, 0x0F, 0x1C, 0xF1, 0x9D, 0x2B, 0xDD,
        0x62, 0xD7, 0x3C, 0x0A, 0x94, 0x79, 0x48, 0xB5,
        0xEE, 0xEA, 0x65, 0xA8, 0x26, 0x8C, 0x79, 0x2B,
        0xDD, 0x17, 0xE0, 0xF6, 0xE6, 0xAC, 0x7B, 0xE4,
        0x65, 0x9C, 0x2E, 0xB7, 0x89, 0xE2, 0x84, 0x17,
        0xA0, 0xD6, 0x95, 0xFE, 0xA9, 0x54, 0x6A, 0x28,
        0x52, 0xBB, 0xED, 0xCF, 0xE3, 0xE9, 0xB4, 0x53,
        0x44, 0xCC, 0x22, 0x04, 0x66, 0x4F, 0x8D, 0x1E,
        0xE1, 0x58, 0xC5, 0x60, 0x39, 0x26, 0xD0, 0xC5,
        0x00, 0x4C, 0xF1, 0xB3, 0x07, 0xCA, 0x89, 0x53,
        0xB0, 0x58, 0x67, 0x93, 0x07, 0x55, 0x4F, 0xAA,
        0x86, 0x9A, 0x9E, 0x45, 0x16, 0xA0, 0xC9, 0x14,
        0xDB, 0x30, 0x93, 0x21, 0x31, 0x33, 0x91, 0x7F,
        0xBA, 0x68, 0x3D, 0x19, 0xD5, 0x94, 0xAA, 0x20,
        0xDB, 0xBA, 0x9E, 0xB5, 0xE6, 0x3B, 0xA6, 0x50,
        0xF7, 0x35, 0x58, 0xEB, 0x7D, 0xA4, 0xC4, 0xF8,
        0x65, 0x9B, 0x8B, 0xF4, 0xF2, 0x52, 0x0F, 0x83,
        0x29, 0xA4, 0x99, 0x55, 0x0E, 0x1D, 0x26, 0x4F,
        0x28, 0x21, 0x73, 0x33, 0x9E, 0x32, 0x3F, 0xF5,
        0xC2, 0x36, 0x65, 0x57, 0x89, 0x54, 0xE1, 0xC1,
        0x61, 0x94, 0xE7, 0xBF, 0x64, 0xCF, 0xD0, 0x1D,
        0x19, 0xE3, 0x45, 0x44, 0x02, 0xD0, 0xAA, 0xF4,
        0x99, 0xDB, 0x31, 0xAD, 0xD5, 0xB5, 0xC1, 0x9A,
        0xA6, 0xC0, 0x3F, 0x20, 0x29, 0x58, 0x37, 0x03,
        0x0A, 0x18, 0xA7, 0x00, 0xD1, 0xA1, 0xA8, 0x73,
        0x00, 0x22, 0x91, 0x04, 0x3B, 0x2B, 0x11, 0xB3,
        0xD5, 0x50, 0x5E, 0x8E, 0x6A, 0xD4, 0xB4, 0x69,
        0x0E, 0xFA, 0x69, 0xE4, 0x80, 0x3B, 0x30, 0xA9,
        0x12, 0x84, 0x84, 0xD9, 0x8E, 0x4F, 0x3E, 0x87,
        0xB8, 0x76, 0x62, 0xA5, 0x4B, 0x10, 0xCD, 0xF2,
        0x8C, 0xF4, 0x88, 0x0F, 0xDF, 0xD7, 0x12, 0x46,
        0x35, 0xB9, 0x53, 0xD1, 0x0A, 0x7D, 0xAC, 0xFA,
        0x0B, 0xDC, 0xDC, 0x96, 0x76, 0xE2, 0xB4, 0xCC,
        0x5B, 0x44, 0x98, 0x03, 0xAA, 0xDF, 0x50, 0xBC,
        0x6B, 0x55, 0xCF, 0x3C, 0x7F, 0xB9, 0x7A, 0x7B,
        0x64, 0x71, 0x5F, 0x9E, 0x82, 0x2F, 0xF5, 0x2B,
        0x23, 0xC9, 0x57, 0xC7, 0x6D, 0x73, 0xC9, 0x37,
        0xCC, 0x04, 0x21, 0xE3, 0x2E, 0xF8, 0x09, 0xD4,
        0x50, 0xE6, 0xD6, 0x8F, 0x38, 0x33, 0x58, 0x75,
        0xB2, 0x41, 0x37, 0x62, 0x91, 0xA2, 0x2E, 0x2D,
        0x1D, 0x51, 0xFA, 0x42, 0xA4, 0xA2, 0xBD, 0x01,
        0x3E, 0x09, 0x99, 0x52, 0x9F, 0x9B, 0xCA, 0x31,
        0xC5, 0xF4, 0x75, 0x5A, 0xA2, 0xC8, 0xF7, 0xF6,
        0xA1, 0xA1, 0x92, 0xFF, 0xD1, 0x72, 0x36, 0x34,
        0x21, 0xCD, 0x2E, 0x3F, 0xE3, 0x50, 0x60, 0x83,
        0x7C, 0xDA, 0xDE, 0x40, 0xA3, 0x49, 0x24, 0x79,
        0xA5, 0x53, 0x52, 0x62, 0xE7, 0xD4, 0x35, 0x98,
        0x1B, 0xFA, 0x3D, 0x13, 0x0F, 0x7A, 0x24, 0x75,
        0x3B, 0x05, 0x4C, 0xE2, 0x2B, 0x55, 0x5C, 0x99,
        0x83, 0x45, 0x4A, 0xA3, 0x04, 0x93, 0xBE, 0x10,
        0xD9, 0xD1, 0x44, 0x21, 0x7F, 0xED, 0x25, 0xAA,
        0xF5, 0x2F, 0xA7, 0x0D, 0x70, 0x2E, 0x40, 0x5F,
        0x23, 0xF5, 0x12, 0xAD, 0x15, 0xEC, 0x96, 0xDA,
        0x20, 0xBB, 0xC2, 0x9A, 0x43, 0xB8, 0xA0, 0x7C,
        0x2B, 0xA2, 0x07, 0x30, 0x5E, 0x62, 0xE8, 0x45,
        0xF5, 0x85, 0xB0, 0x53, 0xCB, 0x5B, 0xF1, 0x45,
        0xBA, 0x50, 0x4F, 0x8A
    },
    {
        MAC_ADDR_0_0, MAC_ADDR_0_1, MAC_ADDR_0_2, MAC_ADDR_0_3, MAC_ADDR_0_4, MAC_ADDR_0_5,
        MAC_ADDR_1_0, MAC_ADDR_1_1, MAC_ADDR_1_2, MAC_ADDR_1_3, MAC_ADDR_1_4, MAC_ADDR_1_5,
        0x08, 0x00,
        0x00, 0x00, 0x00, 0x00,
        0x50, 0x3B, 0x9B, 0x15, 0x8D, 0x29, 0x27, 0xD9,
        0x14, 0xE8, 0x9C, 0xBB, 0x5F, 0x9F, 0xCE, 0xD5,
        0x68, 0xB1, 0x51, 0xC2, 0x35, 0x3B, 0x37, 0xD4,
        0x6C, 0xD3, 0x40, 0x60, 0x4C, 0x8B, 0x8B, 0x73,
        0x98, 0x9E, 0xF1, 0x8B, 0x5E, 0x16, 0x8F, 0x19,
        0x7C, 0xF6, 0xE7, 0xF6, 0x9D, 0x24, 0x23, 0x7C,
        0xD7, 0x7B, 0xEE, 0x92, 0x9A, 0x13, 0x7F, 0x1F,
        0x78, 0xA4, 0x63, 0x21, 0xD3, 0x47, 0xCB, 0x68,
        0xEA, 0xA2, 0xA8, 0x41, 0x06, 0x30, 0x07, 0x05,
        0x72, 0xF1, 0x3D, 0x2D, 0xB7, 0x7C, 0x88, 0xDA,
        0x86, 0x29, 0x65, 0x97, 0xC3, 0x7D, 0x9C, 0x66,
        0x1B, 0xBC, 0xFC, 0x6D, 0x26, 0xB0, 0x5F, 0xE1,
        0x33, 0x38, 0x70, 0x95, 0xEB, 0xFA, 0xB6, 0x57,
        0xE1, 0xBC, 0x5F, 0xFA, 0xA8, 0x3F, 0x26, 0xAB,
        0xA3, 0xD4, 0x40, 0x51, 0xE0, 0x7F, 0xD8, 0x6C,
        0x81, 0x87, 0xF6, 0x69, 0xEB, 0xCB, 0x5A, 0xFD,
        0xB0, 0xA0, 0x4F, 0x32, 0x51, 0xFD, 0x95, 0xC4,
        0xD0, 0x98, 0x83, 0x9B, 0xBC, 0xB9, 0xCB, 0x1A,
        0xFD, 0x53, 0xE6, 0xB6, 0x07, 0x41, 0x85, 0xBA,
        0x16, 0x5E, 0xD3, 0x5C, 0xE7, 0x1B, 0xF2, 0xF5,
        0x4B, 0x5D, 0x0D, 0x6C, 0xD9, 0x86, 0xCC, 0x8A,
        0x2E, 0x0D, 0x38, 0x00, 0x75, 0x2F, 0x10, 0xC3,
        0x32, 0x6B, 0x78, 0xA4, 0x46, 0x8D, 0x34, 0xED,
        0x72, 0x3C, 0xF8, 0xE4, 0x28, 0x33, 0x8F, 0x54,
        0x2B, 0xAC, 0x0C, 0x26, 0x3B, 0xE2, 0x99, 0xA1,
        0x92, 0x13, 0xCE, 0xBC, 0xC1, 0x6E, 0xFB, 0x73,
        0xB6, 0xA6, 0x4B, 0x1D, 0xEA, 0x74, 0x47, 0x97,
        0xB1, 0x41, 0x08, 0x1D, 0xB7, 0x79, 0x1C, 0xA8,
        0x0E, 0x0A, 0x21, 0x21, 0x43, 0x75, 0xFF, 0xDF,
        0x30, 0x22, 0xBA, 0x10, 0xF1, 0x06, 0x81, 0xA5,
        0x34, 0xD4, 0x85, 0xC6, 0xA6, 0xD3, 0x3E, 0x5B,
        0xCF, 0x45, 0xD3, 0x24, 0x39, 0xAA, 0x4C, 0xC8,
        0xAF, 0xB4, 0xD8, 0x35, 0xD6, 0x9B, 0xEA, 0x45,
        0xC0, 0x50, 0x37, 0x40, 0x30, 0x8C, 0xD6, 0x2B,
        0x7A, 0x2A, 0x8B, 0x5B, 0xEB, 0xF4, 0x02, 0x04,
        0xEC, 0x23, 0x94, 0x60, 0xB4, 0x3B, 0xCD, 0x06,
        0x0B, 0x67, 0x8C, 0xD8, 0x89, 0x77, 0x06, 0x55,
        0xBA, 0x61, 0x9E, 0x03, 0xA6, 0x68, 0xBD, 0x3C,
        0x00, 0x29, 0xEC, 0xAE, 0xC4, 0x49, 0x35, 0x52,
        0x04, 0xF9, 0xE0, 0x35, 0xD8, 0xD5, 0x3D, 0xEC,
        0x2A, 0x0C, 0x26, 0xE8, 0x15, 0xDA, 0xAD, 0x73,
        0x76, 0xC7, 0xE5, 0xC1, 0x2C, 0xF5, 0x67, 0x9E,
        0xFB, 0x25, 0x0C, 0x35, 0x95, 0x2F, 0xC5, 0x5A,
        0x19, 0x6D, 0xB8, 0x3E, 0x3E, 0x66, 0xF3, 0xF0,
        0xF0, 0x66, 0x8F, 0x6D, 0x08, 0xAB, 0xB6, 0x2A,
        0x39, 0x82, 0x83, 0x98, 0x8D, 0x9D, 0xF1, 0x58,
        0x67, 0x6F, 0x3F, 0x89, 0x84, 0xDA, 0x1D, 0x9C,
        0xB0, 0x72, 0x14, 0xD1, 0x25, 0xE4, 0x7E, 0x69,
        0xAD, 0xA9, 0x27, 0xAF, 0x87, 0x6D, 0xF4, 0x3A,
        0x25, 0xBA, 0xCD, 0xEE, 0xAA, 0x48, 0xB0, 0x16,
        0x2C, 0x0C, 0xE1, 0x6E, 0x1B, 0xFE, 0xF4, 0x45,
        0xB3, 0x33, 0xF2, 0x96, 0x95, 0xA3, 0x46, 0x77,
        0x65, 0x29, 0xF7, 0xD9, 0x9D, 0x9D, 0xB7, 0x75,
        0xE7, 0x2D, 0x6D, 0x9B, 0x07, 0x12, 0x18, 0x8E,
        0x16, 0xFF, 0x08, 0x9D, 0xCD, 0x4A, 0x5A, 0xF8,
        0x7F, 0x1C, 0x4C, 0xD3, 0x31, 0x7A, 0x8F, 0x11,
        0x05, 0x75, 0x68, 0x47, 0xA2, 0x8F, 0xA8, 0x41,
        0x6B, 0x2E, 0x42, 0xBF, 0x49, 0xCF, 0x07, 0x92,
        0x69, 0x60, 0x29, 0x61, 0x5D, 0x0A, 0xFC, 0x81,
        0x28, 0x36, 0x10, 0x23, 0x9E, 0xE5, 0x02, 0xCB,
        0x8A, 0x3F, 0x9F, 0xA6, 0x14, 0xDA, 0xD6, 0xA4,
        0xB9, 0x04, 0x78, 0x9F, 0x37, 0x57, 0xA2, 0x0C,
        0xB4, 0xEF, 0x2C, 0xFA, 0x44, 0x85, 0x28, 0x46,
        0x80, 0x25, 0x09, 0xBA, 0xE0, 0x88, 0xDD, 0x79,
        0xBA, 0xD5, 0xAC, 0x88, 0xE1, 0x72, 0x1A, 0x4A,
        0xDE, 0x27, 0xF6, 0x96, 0xBC, 0x90, 0xE0, 0x0F,
        0xD7, 0xFB, 0xAB, 0xAC, 0x9D, 0xE2, 0xAC, 0x22,
        0x4A, 0xCC, 0xA4, 0x8A, 0x86, 0x3E, 0x29, 0x05,
        0xAC, 0x23, 0x28, 0xB6, 0x45, 0xA0, 0xE7, 0x02,
        0x0D, 0x95, 0xAC, 0x79, 0x51, 0x74, 0x71, 0xF9,
        0x8B, 0xF0, 0x24, 0xEF, 0x85, 0x24, 0xD5, 0x9C,
        0xDF, 0x76, 0x3C, 0x23, 0xB9, 0xA7, 0x26, 0xF0,
        0x71, 0x29, 0x8C, 0xF7, 0xB7, 0x85, 0xC2, 0x84,
        0x8C, 0xC7, 0xD2, 0x04, 0x55, 0xA7, 0x47, 0x55,
        0x7A, 0x82, 0xC9, 0x7A, 0x1D, 0x07, 0x7E, 0x8A,
        0xE9, 0x70, 0xAF, 0x7B, 0x7A, 0xE2, 0x75, 0x8E,
        0x05, 0xFE, 0xC3, 0x59, 0x69, 0xDA, 0x99, 0xAA,
        0xC6, 0xCC, 0x98, 0x7B, 0x76, 0x42, 0x3E, 0xB3,
        0xC5, 0x8A, 0x9B, 0x2B, 0xCD, 0xFF, 0x89, 0xA7,
        0x9C, 0x2D, 0xAC, 0xA2, 0xE5, 0xF9, 0xC5, 0x34,
        0x06, 0xC9, 0x58, 0x8B, 0x48, 0xF9, 0xBD, 0xF8,
        0x19, 0xDC, 0x25, 0x7E, 0x95, 0x53, 0x42, 0xC4,
        0xE7, 0x42, 0xF0, 0xF5, 0xD0, 0xA2, 0x93, 0x8F,
        0x54, 0x9B, 0xE1, 0x64, 0x6F, 0x67, 0xB7, 0x2A,
        0xDF, 0x13, 0x37, 0xB8, 0xE3, 0xE7, 0x3A, 0x23,
        0x19, 0xF2, 0x0F, 0xF6, 0x80, 0xF4, 0x5E, 0x19,
        0x76, 0x5C, 0x98, 0x3A, 0x9C, 0x8C, 0xF6, 0xCA,
        0x05, 0x24, 0x11, 0x6E, 0xDB, 0xE1, 0xB2, 0xC4,
        0x45, 0xA6, 0x3F, 0xFD, 0x9D, 0xC8, 0x36, 0x22,
        0x6D, 0x17, 0xF2, 0x64, 0x8E, 0x74, 0x8D, 0x5E,
        0x6D, 0xF9, 0xA9, 0x5F, 0x26, 0x55, 0x7F, 0x21,
        0x21, 0x55, 0x18, 0xD9, 0xFA, 0x57, 0xE9, 0x44,
        0x6E, 0xD1, 0x3B, 0x54, 0xC8, 0xC0, 0x28, 0x92,
        0xC5, 0xAA, 0x05, 0x3C, 0xB6, 0x8E, 0x3B, 0x72,
        0xC6, 0xBB, 0xD3, 0x57, 0x8B, 0x6D, 0x02, 0x50,
        0x89, 0x3F, 0xBF, 0x59, 0xAF, 0x8D, 0x3D, 0x6A,
        0xB2, 0x89, 0xE6, 0x96, 0x26, 0x96, 0x3D, 0x7B,
        0x34, 0xC2, 0x4C, 0xF3, 0x0C, 0xAD, 0x6E, 0xB4,
        0x52, 0x1F, 0x47, 0x2C, 0x57, 0x96, 0x62, 0xF9,
        0x3C, 0x92, 0xDD, 0x73, 0x49, 0xC1, 0x31, 0xC7,
        0xC9, 0xA4, 0x9C, 0xD5, 0xC2, 0xDB, 0xC5, 0x52,
        0x9B, 0xB2, 0x92, 0xE4, 0xCE, 0x22, 0x36, 0xB6,
        0xC5, 0xCA, 0xC8, 0xC3, 0xE2, 0x30, 0x81, 0xC5,
        0xED, 0x21, 0xA4, 0x6F, 0x3F, 0x6D, 0x8C, 0x39,
        0x64, 0x9B, 0xBB, 0x61, 0xC9, 0x53, 0x63, 0x2C,
        0xC2, 0x03, 0xE3, 0x15, 0xB8, 0xF3, 0x32, 0xA4,
        0x80, 0x3A, 0x8C, 0x07, 0x52, 0xDE, 0xF2, 0x3B,
        0x15, 0x26, 0x77, 0xD8, 0x50, 0x86, 0xAF, 0xEB,
        0x3B, 0x25, 0x2F, 0x3A, 0xA6, 0x72, 0xD8, 0xCC,
        0x3A, 0xCF, 0x43, 0x0B, 0xE6, 0xEE, 0xAD, 0x9E,
        0xD9, 0x0C, 0x03, 0x41, 0x58, 0xE6, 0x30, 0x2B,
        0x34, 0x94, 0x05, 0xBC, 0x3D, 0x61, 0x04, 0x3C,
        0xAF, 0x13, 0xAE, 0xE3, 0x21, 0xBC, 0xF9, 0x60,
        0x57, 0xA5, 0xA2, 0xBC, 0x8F, 0x7C, 0x93, 0xE3,
        0x7B, 0xB2, 0xE2, 0x2E, 0xE5, 0xD7, 0xA7, 0x05,
        0x59, 0xB0, 0xBE, 0x18, 0x9D, 0x2E, 0xA1, 0x2F,
        0x39, 0xA0, 0xD4, 0x40, 0xED, 0x51, 0x12, 0x2B,
        0xE1, 0x0D, 0x63, 0xF2, 0x74, 0xED, 0x0A, 0xFB,
        0x52, 0xAB, 0x33, 0x2E, 0x91, 0xE7, 0x89, 0x3A,
        0x2D, 0xAC, 0xA2, 0x18, 0x6E, 0x7F, 0x66, 0xB3,
        0xB9, 0xFA, 0x15, 0xA0, 0xE1, 0x5C, 0x0C, 0x15,
        0x0C, 0x80, 0x4F, 0x5B, 0xBC, 0x65, 0xB9, 0x3D,
        0x07, 0x70, 0x3B, 0xC1, 0x82, 0xD0, 0x01, 0x16,
        0x0B, 0x2F, 0x15, 0x33, 0x4B, 0xBE, 0x4F, 0xF1,
        0x8C, 0x8B, 0xF2, 0xC9, 0xB3, 0x1B, 0x9F, 0x59,
        0x92, 0x8D, 0xD6, 0xCF, 0x2C, 0x67, 0xF6, 0x40,
        0x1A, 0x91, 0xB4, 0x4F, 0x49, 0x0B, 0x9D, 0x8A,
        0xFF, 0xFB, 0xAC, 0x7A, 0x44, 0xE2, 0x1F, 0x30,
        0xBF, 0x4F, 0xB0, 0xEF, 0xF2, 0x93, 0x47, 0x58,
        0x6D, 0x22, 0x87, 0x4F, 0xB2, 0xFC, 0xFC, 0xFA,
        0x3A, 0x40, 0xF5, 0xAD, 0x72, 0x1D, 0xA1, 0xE3,
        0x8B, 0x96, 0x66, 0x7A, 0x8F, 0x17, 0xCA, 0x45,
        0x91, 0xBF, 0xC8, 0x75, 0x11, 0xB1, 0x5E, 0x6D,
        0x87, 0xEB, 0x73, 0xBE, 0xC5, 0x49, 0xD9, 0xC4,
        0x87, 0xCB, 0xF8, 0x4D, 0xB5, 0x11, 0x48, 0xD9,
        0x98, 0x2F, 0x5A, 0x00, 0xE4, 0x5D, 0x3B, 0x11,
        0x33, 0x77, 0x20, 0xAB, 0x09, 0xE2, 0x8A, 0x3A,
        0x06, 0x83, 0xB1, 0x47, 0x65, 0xCD, 0x02, 0x94,
        0x3B, 0x99, 0x5B, 0xD5, 0x1E, 0x1E, 0x17, 0x6B,
        0x51, 0xEB, 0x6C, 0x59, 0x46, 0x77, 0xE1, 0x3A,
        0xCE, 0x59, 0xEA, 0xB1, 0x35, 0xA4, 0x64, 0x3C,
        0x26, 0xB0, 0xE4, 0x0E, 0x35, 0x30, 0xCB, 0x9B,
        0xFD, 0xFE, 0x25, 0x3C, 0xD3, 0xB6, 0x66, 0x71,
        0x56, 0x31, 0xEC, 0xE8, 0x63, 0xE3, 0xAD, 0x36,
        0xDB, 0x6D, 0x7B, 0x86, 0x35, 0xCD, 0xB3, 0x20,
        0x5E, 0x77, 0x7D, 0x8F, 0x19, 0x22, 0x29, 0x9F,
        0x25, 0x0B, 0x60, 0x2A, 0xC8, 0xA4, 0x37, 0x38,
        0x27, 0x78, 0xB3, 0x5F, 0x3D, 0xA4, 0xD8, 0xC1,
        0x80, 0x88, 0xE5, 0xFE, 0x51, 0xA8, 0xB4, 0xCB,
        0x76, 0xE0, 0xD3, 0x50, 0x85, 0x67, 0x5A, 0x68,
        0xE2, 0x31, 0x75, 0xAD, 0x7C, 0x55, 0xB0, 0xE7,
        0x41, 0x0A, 0xD2, 0xEB, 0x2F, 0xF2, 0x7F, 0x79,
        0x6A, 0x05, 0xB1, 0x35, 0x89, 0xA7, 0x02, 0xA0,
        0x94, 0xCC, 0x44, 0x0E, 0xF5, 0xD6, 0xC9, 0x3B,
        0xE3, 0xAE, 0xE6, 0x34, 0xAD, 0x75, 0x38, 0x24,
        0xB4, 0xE0, 0xFB, 0xCC, 0xDC, 0xA7, 0x8C, 0xB8,
        0xAE, 0x7B, 0x60, 0x0C, 0xC6, 0xA2, 0xBB, 0x7F,
        0x6D, 0x99, 0x46, 0x67, 0x37, 0xDA, 0x95, 0xA0,
        0x8B, 0xF6, 0xA3, 0x47, 0x9F, 0xF7, 0xE5, 0xE4,
        0x50, 0x2E, 0xDD, 0x85, 0x91, 0xF3, 0x6F, 0x3A,
        0x11, 0x2B, 0x53, 0x95, 0x95, 0xF1, 0xD6, 0x52,
        0xD1, 0x42, 0x5E, 0x43, 0x4D, 0xCA, 0x3D, 0xCE,
        0x6D, 0x62, 0x02, 0xF2, 0x83, 0x04, 0xF2, 0xB0,
        0x0F, 0x30, 0x27, 0x3A, 0xD2, 0x41, 0xDE, 0x90,
        0x95, 0x38, 0x62, 0xA5, 0x74, 0x1B, 0x2F, 0x2F,
        0xD5, 0x00, 0x22, 0x7E, 0xE1, 0x04, 0x67, 0x7E,
        0x1A, 0x62, 0xC1, 0x3F, 0x29, 0x39, 0x44, 0x84,
        0xF8, 0x06, 0x86, 0xEA, 0x4A, 0xD8, 0x33, 0x91,
        0x21, 0x54, 0x2D, 0x39, 0x24, 0xB3, 0x31, 0x33,
        0x59, 0x87, 0x99, 0x0B, 0xA6, 0x1E, 0xEC, 0x27,
        0x3F, 0xF7, 0x1A, 0xE9, 0xA9, 0xB5, 0xB6, 0x6F,
        0xE9, 0xAE, 0x3E, 0x51, 0xED, 0x98, 0xD0, 0x59,
        0xCB, 0x2B, 0x03, 0x5F, 0x5E, 0x0D, 0xA1, 0x3A,
        0xB1, 0xE1, 0xF9, 0x1F, 0xD8, 0x96, 0x4E, 0x13,
        0xCD, 0x91, 0x08, 0xF6, 0x1D, 0xFF, 0xFF, 0x59,
        0xFC, 0xE9, 0x08, 0x3D, 0x0E, 0xDA, 0xB9, 0xDD,
        0x34, 0x84, 0x21, 0x64, 0x39, 0xC6, 0x96, 0xEA,
        0xE4, 0x60, 0xCF, 0xDE, 0x5B, 0x79, 0x08, 0xE6,
        0xEE, 0xE1, 0x6D, 0x2D, 0xA3, 0x09, 0xA3, 0x34,
        0xF0, 0x1C, 0x88, 0xA9, 0xD9, 0xA9, 0xEF, 0x7A,
        0x1C, 0xB1, 0x61, 0x09, 0x46, 0x9B, 0xA8, 0xFC,
        0xF6, 0xB2, 0xA8, 0x67, 0x67, 0x14, 0x83, 0x9D,
        0x46, 0xE3, 0x1B, 0x32, 0x52, 0x83, 0x08, 0x16,
        0x54, 0x8D, 0x33, 0x2D, 0x6B, 0xCF, 0x91, 0x99,
        0x39, 0x8B, 0x00, 0xD6, 0xB8, 0x1D, 0x21, 0xC5,
        0x5C, 0x1C, 0xF4, 0x55, 0xF3, 0x4D, 0xDE, 0xE3,
        0xC4, 0xDF, 0xC6, 0xE6, 0x20, 0x21, 0x06, 0x0A,
        0x3D, 0x13, 0x26, 0x2C
    },

};

/* Number of frames to transmit. If 0, it runs continuously. */
#define FRAME_COUNT         (10000)
/* Frame size in bytes, applies to each of the transmitted frames. */
/* The value should be between 64 and 1518. */
#define FRAME_SIZE          (1518)

/* Number of buffer descriptors to use for both Tx and Rx in this example */
#define BUFF_DESC_COUNT     (6)

// #define ADIN1110_INIT_ITER  (5)

/* Example configuration */
// uint8_t devMem[ADIN1110_DEVICE_SIZE];
uint32_t heartbeatCheckTime = 0;

sfe_spe_advanced adin1110;

// adin1110_DriverConfig_t drvConfig = {
//     .pDevMem    = (void *)devMem,
//     .devMemSize = sizeof(devMem),
//     .fcsCheckEn = true,
// };
uint32_t               txIdx = 0;
volatile uint32_t      rxIdx = 0;
volatile uint32_t      expectedTxIdx;
volatile uint32_t      expectedRxIdx;
volatile uint32_t      errorTxIdx;
volatile uint32_t      errorRxIdx;


HAL_ALIGNED_PRAGMA(4)
static uint8_t rxBuf[BUFF_DESC_COUNT][MAX_FRAME_BUF_SIZE] HAL_ALIGNED_ATTRIBUTE(4);

HAL_ALIGNED_PRAGMA(4)
static uint8_t txBuf[BUFF_DESC_COUNT][MAX_FRAME_BUF_SIZE] HAL_ALIGNED_ATTRIBUTE(4);

bool txBufAvailable[BUFF_DESC_COUNT];

static void txCallback(void *pCBParam, uint32_t Event, void *pArg)
{
    adi_eth_BufDesc_t       *pTxBufDesc;
    uint32_t                idx;

    pTxBufDesc = (adi_eth_BufDesc_t *)pArg;
    txIdx++;

    memcpy(&idx, &pTxBufDesc->pBuf[14], 4);

    /* Log a Tx index error if current frame index does not match expected value */
    if (idx != expectedTxIdx)
    {
        errorTxIdx++;
    }
    /* Next frame is expected to have an index incremented by 1 from the current frame index. */
    expectedTxIdx = idx + 1;

    /* Buffer has been written to the ADIN1110 Tx FIFO, we mark it available */
    /* to re-submit to the Tx queue with updated contents. */
    for (uint32_t i = 0; i < BUFF_DESC_COUNT; i++)
    {
        if (&txBuf[i][0] == pTxBufDesc->pBuf)
        {
            txBufAvailable[i] = true;
            break;
        }
    }
}

static void rxCallback(void *pCBParam, uint32_t Event, void *pArg)
{
    adin1110_DeviceHandle_t hDevice = (adin1110_DeviceHandle_t)pCBParam;
    adi_eth_BufDesc_t       *pRxBufDesc;
    uint32_t                idx;

    pRxBufDesc = (adi_eth_BufDesc_t *)pArg;
    rxIdx++;

    memcpy(&idx, &pRxBufDesc->pBuf[14], 4);

    /* Log an Rx index error if current frame index does not match expected value */
    if (idx != expectedRxIdx)
    {
        errorRxIdx++;
    }
    /* Next frame is expected to have an index incremented by 1 from the current frame index. */
    expectedRxIdx = idx + 1;

    /* Since we're not doing anything with the Rx buffer in this example, */
    /* we are re-submitting it to the queue. */
    adin1110.submitRxBuffer(pRxBufDesc);
}

void cbLinkChange(void *pCBParam, uint32_t Event, void *pArg)
{
    adi_eth_LinkStatus_e    linkStatus;

    linkStatus = *(adi_eth_LinkStatus_e *)pArg;

    (void)linkStatus;
}

void setup() 
{
    adi_eth_Result_e        result;
    uint32_t                error;
    uint32_t                heartbeatCheckTime = 0;
    Serial.begin(115200);
    while (!Serial) {
      ; // wait for serial port to connect. Needed for native USB port only
    }
    /****** System Init *****/
    result = adin1110.begin();
    if(result != ADI_ETH_SUCCESS) Serial.println("No MACPHY device found");
    else Serial.println("Adin1110 found!");

    result = adin1110.addAddressFilter(&macAddr[0][0], NULL, 0);
    if(result != ADI_ETH_SUCCESS) Serial.println("adin1110_AddAddressFilter");

    result = adin1110.addAddressFilter(&macAddr[1][0], NULL, 0);
    if(result != ADI_ETH_SUCCESS) Serial.println("adin1110_AddAddressFilter");

    result = adin1110.syncConfig();
    if(result != ADI_ETH_SUCCESS) Serial.println("adin1110_SyncConfig");

    result = adin1110.registerCallback(cbLinkChange, ADI_MAC_EVT_LINK_CHANGE);
    if(result != ADI_ETH_SUCCESS) Serial.println("adin1110_RegisterCallback (ADI_MAC_EVT_LINK_CHANGE)");

    adi_eth_BufDesc_t       rxBufDesc[BUFF_DESC_COUNT];
    uint32_t                txBufDescIdx = 0;
    adi_eth_BufDesc_t       txBufDesc[BUFF_DESC_COUNT];
    uint32_t                testFramesIdx = 0;
    adi_eth_LinkStatus_e    linkStatus;
    uint32_t                frameIdx;
    uint32_t                heartbeatTicks;

    /* Prepare Tx/Rx buffers */
    for (uint32_t i = 0; i < BUFF_DESC_COUNT; i++)
    {
        memcpy(&txBuf[i], &testFrames[i % 2][0], FRAME_SIZE);
        txBufAvailable[i] = true;

        rxBufDesc[i].pBuf = &rxBuf[i][0];
        rxBufDesc[i].bufSize = MAX_FRAME_BUF_SIZE;
        rxBufDesc[i].cbFunc = rxCallback;

        result = adin1110.submitRxBuffer(&rxBufDesc[i]);
    }

    result = adin1110.enable();
    if(result != ADI_ETH_SUCCESS) Serial.println("Device enable error");

    /* Wait for link to be established */
    do
    {
        result = adin1110.getLinkStatus(&linkStatus);
        if(result != ADI_ETH_SUCCESS) Serial.println("adin1110_GetLinkStatus failed");
    } while (linkStatus != ADI_ETH_LINK_STATUS_UP);

    /* Reset buffer descriptor index */
    expectedRxIdx = 0;
    expectedTxIdx = 0;

    errorTxIdx = 0;
    errorRxIdx = 0;

    frameIdx = 0;
    heartbeatTicks = 0;
    /* if FRAME_COUNT == 0, run in an infinite loop. */
    while (!FRAME_COUNT || (txIdx < FRAME_COUNT))
    {
        uint32_t now  = BSP_SysNow();

        /* Heartbeat pulse approximately once every 250ms. */
        if (now - heartbeatCheckTime >= 250)
        {
            heartbeatCheckTime = now;
            BSP_HeartBeat();
            heartbeatTicks++;
        }

        if (txBufAvailable[testFramesIdx])
        {
            txBufDesc[txBufDescIdx].pBuf = &txBuf[testFramesIdx][0];
            txBufDesc[txBufDescIdx].trxSize = FRAME_SIZE;
            txBufDesc[txBufDescIdx].bufSize = MAX_FRAME_BUF_SIZE;
            txBufDesc[txBufDescIdx].egressCapt = ADI_MAC_EGRESS_CAPTURE_NONE;
            txBufDesc[txBufDescIdx].cbFunc = txCallback;

            /* Update the frame contents to include the frame index */
            uint32_t *p = (uint32_t *)&txBufDesc[txBufDescIdx].pBuf[14];
            *p = frameIdx;

            txBufAvailable[testFramesIdx] = false;

            result = adin1110.submitTxBuffer(&txBufDesc[txBufDescIdx]);
            if (result == ADI_ETH_SUCCESS)
            {
                txBufDescIdx++;
                if (txBufDescIdx >= BUFF_DESC_COUNT)
                {
                    txBufDescIdx = 0;
                }

                testFramesIdx++;
                if (testFramesIdx >= BUFF_DESC_COUNT)
                {
                    testFramesIdx = 0;
                }

                frameIdx++;
            }
            else
            {
                /* If Tx buffer submission fails (for example the Tx queue */
                /* may be full), then mark the buffer unavailable.  */
                txBufAvailable[testFramesIdx] = true;
            }
        }

        /* Report stats every ~2 seconds. */
        if (heartbeatTicks >= 8)
        {
            heartbeatTicks = 0;
            printStats();
        }

    }

    delay(500);


    printStats();

    result = adin1110.unInit();

}

void printStats()
{
    adi_eth_Result_e            result = ADI_ETH_SUCCESS;
    adi_eth_MacStatCounters_t   stats;
    bool                        fail;

    result = adin1110.getStatCounters(&stats);
    DEBUG_RESULT("adin1110_GetStatCounters", result, ADI_ETH_SUCCESS);

    fail = false;
    fail = fail || (errorTxIdx || errorRxIdx);
    fail = fail || (stats.RX_CRC_ERR_CNT > 0);
    fail = fail || (stats.RX_ALGN_ERR_CNT > 0);
    fail = fail || (stats.RX_LS_ERR_CNT > 0);
    fail = fail || (stats.RX_PHY_ERR_CNT > 0);
    fail = fail || (stats.RX_DROP_FULL_CNT > 0);
    fail = fail || (stats.RX_DROP_FILT_CNT > 0);

    if (fail)
    {
        DEBUG_MESSAGE("Result: FAIL\r");
        DEBUG_MESSAGE("    Tx index errors: %d\r", errorTxIdx);
        DEBUG_MESSAGE("    Rx index errors: %d\r", errorRxIdx);
        BSP_ErrorLed(true);
    }
    else
    {
        DEBUG_MESSAGE("Result: PASS\r");
    }
    DEBUG_MESSAGE("Summary:\r");
    DEBUG_MESSAGE("     Sent frames:        %d\r", txIdx);
    DEBUG_MESSAGE("     Received frames:    %d\r", rxIdx);
    DEBUG_MESSAGE("     Statistics counters:\r");
    DEBUG_MESSAGE("         TX_FRM_CNT         = %d\r", stats.TX_FRM_CNT);
    DEBUG_MESSAGE("         TX_UCAST_CNT       = %d\r", stats.TX_UCAST_CNT);
    DEBUG_MESSAGE("         TX_MCAST_CNT       = %d\r", stats.TX_MCAST_CNT);
    DEBUG_MESSAGE("         TX_BCAST_CNT       = %d\r", stats.TX_BCAST_CNT);
    DEBUG_MESSAGE("         RX_FRM_CNT         = %d\r", stats.RX_FRM_CNT);
    DEBUG_MESSAGE("         RX_UCAST_CNT       = %d\r", stats.RX_UCAST_CNT);
    DEBUG_MESSAGE("         RX_MCAST_CNT       = %d\r", stats.RX_MCAST_CNT);
    DEBUG_MESSAGE("         RX_BCAST_CNT       = %d\r", stats.RX_BCAST_CNT);
    DEBUG_MESSAGE("         RX_CRC_ERR_CNT     = %d\r", stats.RX_CRC_ERR_CNT);
    DEBUG_MESSAGE("         RX_ALGN_ERR_CNT    = %d\r", stats.RX_ALGN_ERR_CNT);
    DEBUG_MESSAGE("         RX_LS_ERR_CNT      = %d\r", stats.RX_LS_ERR_CNT);
    DEBUG_MESSAGE("         RX_PHY_ERR_CNT     = %d\r", stats.RX_PHY_ERR_CNT);
    DEBUG_MESSAGE("         RX_DROP_FULL_CNT   = %d\r", stats.RX_DROP_FULL_CNT);
    DEBUG_MESSAGE("         RX_DROP_FILT_CNT   = %d\r", stats.RX_DROP_FILT_CNT);

}

void loop() { }